fix: mark IpPrefix::isValid() as const#1213
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
2de76eb to
68fd86c
Compare
|
/azpw run Azure.sonic-swss-common |
|
Retrying failed(or canceled) jobs... |
|
/azp run |
|
No Azure DevOps builds found for #1213. |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks! ---Powered by SONiC BuildBot
|
|
/azpw run Azure.sonic-swss-common |
|
Retrying failed(or canceled) jobs... |
|
Retrying failed(or canceled) stages in build 1144008: ✅Stage Test:
|
|
/azpw run Azure.sonic-swss-common |
|
Retrying failed(or canceled) jobs... |
|
Retrying failed(or canceled) stages in build 1144008: ✅Stage Test:
|
68fd86c to
fac5314
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
fac5314 to
d1780c5
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run Azure.sonic-swss-common |
|
Commenter does not have sufficient privileges for PR 1213 in repo sonic-net/sonic-swss-common |
isValid() only reads m_ip and m_mask — it does not modify any member. Without const, it cannot be called on const IpPrefix objects or const references, making the method unusable in const-correct contexts. Also fix a race condition in LruDedupPolicyConstructorAndLabelPropagation: the drain loop was stopping at the first pops(), but the second Redis message may not have been consumed by readData() yet. Loop until stats.received >= 2 so the assertion is deterministic. Signed-off-by: xq9mend <xq9mend@users.noreply.github.com>
d1780c5 to
7a28830
Compare
Why
IpPrefix::isValid()only readsm_ipandm_mask— it does not modify any member. Withoutconst, it cannot be called onconst IpPrefixobjects orconst IpPrefix&references, making it unusable in const-correct contexts despite all other observer methods (to_string,isV4,getIp, etc.) already being correctly markedconst.How
Add
constto the declaration inipprefix.hand the definition inipprefix.cpp.How to verify
Existing unit tests pass. Additionally, the following now compiles correctly: